using Godot;
using System;

public partial class Killzone : Area2D
{
    private Timer TimerNode;
  
    public override void _Ready()
    {
        TimerNode = GetNode<Timer>("Timer");
        BodyEntered += HandleBodyEntered;
        TimerNode.Timeout += HandleTimeOut;

    }

    private void HandleTimeOut()
    {
        Engine.TimeScale = 1.0f;
        GetTree().ReloadCurrentScene();
    }

    private void HandleBodyEntered(Node2D body)
    {
        Engine.TimeScale = 0.5f;
        body.GetNode("CollisionShape2D").QueueFree();
        TimerNode.Start();
    }
}
